<%@ page import="java.sql.PreparedStatement" %>
<%@ page import="com.example.utils.DButil" %>
<%@ page import="java.sql.SQLException" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="com.example.entity.User" %>
<%@ page import="java.sql.Connection" %><%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2024/12/31
  Time: 12:08
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<%

    try {
        Class.forName("com.mysql.jdbc.Driver");

        String sql = "UPDATE userinfo SET USERIMG = ? WHERE USER_ID = ?";
        Connection connection = DButil.getConnection();
        PreparedStatement ps = connection.prepareStatement(sql);
        ps.setString(1, request.getParameter("userimg"));
        ps.setString(2, request.getParameter("userid"));
        ps.executeUpdate();

        User user = (User)request.getSession().getAttribute("user");
        user.setUserimg(request.getParameter("userimg"));
        request.getSession().setAttribute("user", user);
    } catch (SQLException e) {
        throw new RuntimeException(e);
    } catch (ClassNotFoundException e) {
        throw new RuntimeException(e);
    }
%>
<body>

</body>
</html>
